
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<div class="main">
<div class="orderlist">
	<p class="tt"><a>首页</a>><a href="orderlist.php">订单管理</a>><span>订单列表</span></p>
	<div class="div">
		<form method='GET' action="?" class='search' >
			<input type="hidden" name="cplx" value="{$cplx}" />
			<p><span>收件人</span><input type='text' name='tname' style='width:110px;' placeholder='收货人姓名' value="{$tname}" /></p>
			<p><span>下单用户账户</span><input type='text' name='uname' style='width:130px;' placeholder='下单用户' value="{$uname}" /></p>
			<p><span>订单编号</span><input style='width:155px;' type='text' name='ocode' placeholder='订单编号' value="{$ocode}" /></p>
			<p><span>回寄单号</span><input style='width:155px;' type='text' name='hjocode' placeholder='回寄快递编号' value="{$hjocode}" /></p>
			<p><span>下单时间</span><input type='date' name='time' value="{$time}" /></p>			
			{if($type==1)}
			<p><span>订单状态</span>
				<select name='state'>
					<option {if($state==5)} selected {/if} value='5' >全部订单</option>
					<option {if($state==2)} selected {/if} value='2'>{$osarr1[2]}</option>
					<option {if($state==3)} selected {/if} value='3'>{$osarr1[3]}</option>
					<option {if($state==4)} selected {/if} value='4'>{$osarr1[4]}</option>
				</select>
			</p>
			{else}			
			<p><span>订单状态</span>
				<select name='state'>
					<option {if($state==5)} selected {/if} value='5' >全部订单</option>
					<option {if($state==1)} selected {/if} value='1'>{$osarr2[1]}</option>
					<option {if($state==2)} selected {/if} value='2'>{$osarr2[2]}</option>
					<option {if($state==3)} selected {/if} value='3'>{$osarr2[3]}</option>
					<option {if($state==4)} selected {/if} value='4'>{$osarr2[4]}</option>
				</select>
			</p>			
			{/if}

			<p><input type='submit' value='立即搜索' /></p>
			<a class="dc abtn2" style="float:right; width:auto;" href="excel.php?act=orderlist&tname={$tname}&uname={$uname}&time={$time}&state={$state}&cplx={$cplx}&ocode={$ocode}&type={$type}" target="main">导出订单</a>
		</form>
	</div>
	
	<form action="upfiel_excel.php?cplx={$cplx}" method="post" enctype="multipart/form-data">
		<div class="shanchuan">
			<span>导入订单：</span>
			<input type="file" name="file" id="file">
			<input type="text" class="file-upload-input" name="copyFile">
			<button type="button" class="file-upload-button" tabindex="-1">选择文件</button>
			<input type="submit" name="submit" value="确认更新" style="width:100px;">
		</div>
	</form>
	
	<style>
		 form.file input[type='file']{
			border: 1px solid #ddd;
		}
		
	</style>
	<div class="list">
{if($msg==0)}
	<p class='none'>未查询到资料</p>
{else}
		<table>
		<tr class="after"><th>ID</th><th>账号</th><th>姓名</th><th>电话</th><th>产品</th><th>金额</th><th>支付方式</th><th>下单时间</th><th>发货时间</th><th>完成时间</th>
			{if($cplx<3)}
			<th>回寄时间</th><th>确认时间</th>
			{/if}
			<th>状态</th><th>操作</th></tr>
{loop $olist $key as $list}
	<tr class="remove">
		<td>{$list[px]}</td>
		<td>{$list[uname]}</td>
		<td>{$list[tname]}</td>
		<td style="text-align:center;">{$list[phone]}</td>
		<td class="gleft">{$list[content]}</td>
		<td>{$list[cash]}
			
			<a class="jl abtn2" data-id="{$list[Id]}" style=' float:none; display:inline-block; width:auto; padding:0 8px; cursor:pointer;'>查看奖励</a>
			
		</td>		
		<td>{$payarr[$list[pay]]}</td>
		
		<td style="text-align:center;">{$list[addtime]}</td>
		<td style="text-align:center;">{$list[sendtime]}</td>
		<td style="text-align:center;">{if($list['endtime'])}{$list[endtime]}{/if}</td>
		{if($cplx==2)}
		<td style="text-align:center;">{if($list['jhtime'])}{$list[jhtime]}{/if}</td>
		<td style="text-align:center;">{if($list['jhendtime'])}{$list[jhendtime]}{/if}</td>
		{/if}
		<td>
			<font style="background:#eee; border:1px solid #eee; margin-left:5px; display:inline-block; padding:0 5px; border-radius:5px;">
			
			{if($list['type']==2)}
			{$osarr2[$list[state]]}
			{else}
			{$osarr1[$list[state]]}
			{/if}
			
			</font>
			{if($list['jhstate']>0)}
			<font style="color:red; background:#eee; border:1px solid #eee; margin-left:5px; display:inline-block; padding:0 5px; border-radius:5px;">{$hjarr[$list[jhstate]]}</font>
			{/if}
			{if($list['zh']==1)}				
				<a href="orderlist.php?oid={$list[oid]}&cplx=2" style="color:#5eb95e; background:#eee; border:1px solid #eee; margin-left:5px; display:inline-block; padding:0 5px; border-radius:5px;">已置换</a>				
			{/if}
			{if($list['td']==1)}
			<a class='abtn3' style='display:inline-block; padding:0 8px;float:none; width:auto; cursor:pointer;'>已退单</a>
			{/if}
		</td>
		<td style="text-align:center;">
			<a class='abtn1' style='display:inline-block;float:none; ' href='orders.php?oid={$list[Id]}&uid={$uid}&state={$state}&code={$code}&tname={$tname}&uname={$uname}&time={$time}&gname={$gname}&page={$page}&cplx={$cplx}&ocode={$ocode}&type={$type}'>查看</a>
			{if($list['jhstate']==1)}
			<a class='abtn2 jhend' data-id="{$list[Id]}" style='display:inline-block;float:none; width:auto; cursor:pointer;'>回寄完成</a>
			{/if}
			{if($list['cplx']==2 && $list['state']==1)}
			<a class='abtn2 orderqr' data-id="{$list[Id]}" style='display:inline-block;float:none; width:auto; cursor:pointer;'>确认订单</a>
			{/if}
			{if($list['state']>0 and $list['state']<4 && $list['td']==0)}
			<a class='abtn2 console' data-id="{$list[Id]}" style='display:inline-block;float:none; width:auto; cursor:pointer;'>退单</a>
			{/if}
			<a class='abtn3' style='display:inline-block;float:none; cursor:pointer;' href="javascript:" onclick=del({$list[Id]})>删除</a>
		</td>
	</tr>
{/loop}
	</table>
{$page1}
{/if}
		<div class='zc' style='display:none;'></div>
	    <div class='jiangli' style='display:none;'> <a class="cancel"></a>
            <div class="jiangliMain"></div>

        </div>
	<script src="./js/jquery.js"></script>

	<script>
		$(".jiangli").delegate(".cancel","click",function(){
                $(".jiangli,.zc").hide();
                $(".jiangliMain").html("");
            });
            $(".jl").on("click",function(){
                var id = $(this).attr("data-id");
                $.ajax({
                    type:"post",
                    dataType:"json",
                    url:"/Moudel.php?m=g&a=getjllist",
                    data:"id="+id,
                    success:function(d){
                        if(d[0]==0){
                            alert(d[1]);
                        }
                        else{
                            $(".jiangli,.zc").show();
                            $(".jiangliMain").html(d[1]);
                        }
                    }
                });
            });
		$(".console").on("click",function(){
			msg = confirm("确认退单？");
			if(msg==true){
				id = $(this).attr("data-id");
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=g&a=consoleorder",
					data:"id="+id,
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='orderlist.php?uid={$uid}&state={$state}&code={$code}&tname={$tname}&uname={$uname}&time={$time}&gname={$gname}&page={$page}&cplx={$cplx}&ocode={$ocode}&type={$type}&hjocode={$hjocode}';
						}
					}
				});
			}
		});

		$(".file-upload-button").click(function() {
		    $("#file").click();
		});
		// 监听文件输入框的change事件
        $('#file').on('change', function() {
        // 获取文件输入框的值
            var filePath = $(this).val();
        // 使用split函数获取文件名部分
            var fileName = filePath.split('\\').pop();
        // 输出文件名
            $("input[name=copyFile]").val(fileName);
        });
		function del(id){
			var message = confirm("确认删除？删除后不可恢复 请谨慎操作");
			if(message == true){				
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=g&a=orderdel",
					data:"id="+id,
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='orderlist.php?uid={$uid}&state={$state}&code={$code}&tname={$tname}&uname={$uname}&time={$time}&gname={$gname}&page={$page}&cplx={$cplx}&ocode={$ocode}&type={$type}&hjocode={$hjocode}';
						}
					}
				});
			}
			else{
				return false;
			}
		}
		$(".orderqr").on("click",function(){
			msg = confirm("确认审核通过客户置换订单？");
			if(msg==true){
				id = $(this).attr("data-id");
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=g&a=orderqr",
					data:"id="+id,
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='orderlist.php?uid={$uid}&state={$state}&code={$code}&tname={$tname}&uname={$uname}&time={$time}&gname={$gname}&page={$page}&cplx={$cplx}&ocode={$ocode}&type={$type}&hjocode={$hjocode}';
						}
					}
				});
			}
		});
		$(".jhend").on("click",function(){
			msg = confirm("确认已收到客户回寄产品？");
			if(msg==true){
				id = $(this).attr("data-id");
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=g&a=jhend",
					data:"id="+id,
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='orderlist.php?uid={$uid}&state={$state}&code={$code}&tname={$tname}&uname={$uname}&time={$time}&gname={$gname}&page={$page}&cplx={$cplx}&ocode={$ocode}&type={$type}&hjocode={$hjocode}';
						}
					}
				});
			}
		});

		$(".zt").on("click",function(){
			msg = confirm("确认客户已自提？");
			if(msg==true){
				id = $(this).attr("data-id");
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=g&a=zt",
					data:"id="+id,
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='orderlist.php?uid={$uid}&state={$state}&code={$code}&tname={$tname}&uname={$uname}&time={$time}&gname={$gname}&page={$page}&cplx={$cplx}&ocode={$ocode}&type={$type}&hjocode={$hjocode}';
						}
					}
				});
			}
		});

		h1 = $(".main").height();
		h2 = $(".orderlist").height();
		if(h2>h1){
			$(".main").css("height","auto");
		}
	</script>
	</div>
</div>
</div>